from django.db import models
from datetime import datetime

class BaseModel(models.Model):
    is_show = models.BooleanField(default=True, verbose_name="是否上架")
    created_time = models.DateField(auto_now_add=True, verbose_name="上架时间")
    updated_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    @property
    def get_created_time(self):
        return self.created_time.strftime("%Y-%m-%d")

    @property
    def get_updated_time(self):
        return self.updated_time.strftime("%Y-%m-%d %H:%M:%S")


    # 配置
    class Meta:
        # 不会创建该表，可以被继承
        abstract = True